#include<iostream>
#include <netdb.h>
#include <arpa/inet.h>      /* inet_ntoa() to format IP address */
#include <netinet/in.h>     /* in_addr structure */
using namespace std;

class TcpClient
{
public:
  TcpClient();
  char* nslookup(char *hostname);
private:
  //  char *hostname;
};

TcpClient::TcpClient()
{
  
}

char* TcpClient::nslookup(char *hostname)
{
  struct hostent *p;
  struct in_addr h_addr;    /* internet address */
  p = gethostbyname(hostname);
  
  h_addr.s_addr = *((unsigned long *) p->h_addr_list[0]);
  //  fprintf(stdout, "%s\n", inet_ntoa(h_addr));
  return inet_ntoa(h_addr);
}


//              struct hostent {
//                char  *h_name;            /* official name of host */
//                char **h_aliases;         /* alias list */
//                int    h_addrtype;        /* host address type */
//                int    h_length;          /* length of address */
//                char **h_addr_list;       /* list of addresses */
//            }
//            #define h_addr h_addr_list[0] /* for backward compatibility */
int main()
{
  TcpClient *a = new TcpClient();
  cout<<a -> nslookup("www.google.com.au")<<endl;
  delete a;
}
